#include<iostream>
#include<algorithm>
using namespace std;
const int N = 100;
int n, m;
char g[N][N];
bool st[N][N];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,1,0,-1 };
int dfs(int x, int y)
{
	st[x][y] = 1;
	int ans = 1;
	for (int i = 0; i < 4; i++) {
		int a = dx[i] + x;
		int b = dy[i] + y;
		if (a < 0 || a >= n || b < 0 || b >= m)continue;
		if (g[a][b] == '0' || st[a][b])continue;
		ans += dfs(a, b);
	}
	return ans;
}
int main()
{
	int ma = -1e9;
	memset(st, 0, sizeof(st));
	memset(g, 'z', sizeof(g));
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> g[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (!st[i][j] && g[i][j] == '1') {
				ma = max(ma, dfs(i, j));
			}
		}
	}
	cout << ma << endl;
	return 0;
}
